#!/bin/sh
#10 2,6,8,10,12,14,16,18,20,22 * * * sh /mn/plugin/bkhost/ckbk.sh >/dev/null
#xxb check
scriptsdir=$(cd `dirname $0`; pwd)/../..
#include libs and pars
. ${scriptsdir}/conf/mn.cnf
######xxb database
xxbsize=''
xxbstime=''
xxbdir='/ftp/backup/xxb'
xxbsubdir=`ls -rtl $xxbdir|tail -1|awk '{print $NF}'`
xxbnewdir=${xxbdir}/${xxbsubdir}
if [[ -d $xxbnewdir ]];then
    xxbsize=`du -sm $xxbnewdir|awk '{print $1}'`
    xxbstime=`ls -rtl $xxbnewdir|tail -1|awk '{print $NF}'|awk -F '.' '{print $NF}'`
    #echo $dataformaturl
    echo "insert into mn_sys_bkrec_dtl_source(seq,source,type,a,b,c,e,f,g,h,i,inserttime)values(seqbkrec_dtl_source.NextVal,'192.168.196.85','ftp','xxbfullbackup',to_char(to_date('$xxbstime','yyyymmdd:hh24miss'),'yyyy-mm-dd hh24:mi:ss'),to_char(to_date('$xxbstime','yyyymmdd:hh24miss'),'yyyy-mm-dd hh24:mi:ss'),'NaN','$xxbsize','notprocess','xxbfull','已完成',sysdate)"
    echo "insert into mn_sys_bkrec_dtl_source(seq,source,type,a,b,c,e,f,g,h,i,inserttime)values(seqbkrec_dtl_source.NextVal,'192.168.196.85','ftp','xxbfullbackup',to_char(to_date('$xxbstime','yyyymmdd:hh24miss'),'yyyy-mm-dd hh24:mi:ss'),to_char(to_date('$xxbstime','yyyymmdd:hh24miss'),'yyyy-mm-dd hh24:mi:ss'),'NaN','$xxbsize','notprocess','xxbfull','已完成',sysdate)">>$dataformaturl
    echo "--NEXT">>$dataformaturl
fi

###vip website 
vipsize=''
vipdbstime=''
vipdbdir='/ftp/backup/webvip'
vipdbsubdir=`ls -rtl $vipdbdir|tail -1|awk '{print $NF}'`
vipdbnewdir=${vipdbdir}/${vipdbsubdir}
if [[ -d $vipdbnewdir ]];then
    vipdbstime="$vipdbsubdir:033600"
    vipsize=`du -sm $vipdbnewdir|awk '{print $1}'`
    echo "insert into mn_sys_bkrec_dtl_source(seq,source,type,a,b,c,e,f,g,h,i,inserttime)values(seqbkrec_dtl_source.NextVal,'192.168.196.85','ftp','vipdbfullbackup',to_char(to_date('$vipdbstime','yyyymmdd:hh24miss'),'yyyy-mm-dd hh24:mi:ss'),to_char(to_date('$vipdbstime','yyyymmdd:hh24miss'),'yyyy-mm-dd hh24:mi:ss'),'NaN','$vipsize','notprocess','vipdbfull','已完成',sysdate)"
    echo "insert into mn_sys_bkrec_dtl_source(seq,source,type,a,b,c,e,f,g,h,i,inserttime)values(seqbkrec_dtl_source.NextVal,'192.168.196.85','ftp','vipdbfullbackup',to_char(to_date('$vipdbstime','yyyymmdd:hh24miss'),'yyyy-mm-dd hh24:mi:ss'),to_char(to_date('$vipdbstime','yyyymmdd:hh24miss'),'yyyy-mm-dd hh24:mi:ss'),'NaN','$vipsize','notprocess','vipdbfull','已完成',sysdate)">>$dataformaturl
    echo "--NEXT">>$dataformaturl
fi



###call website 
callcentersize=''
callcenterstime=''
callcenterdir='/ftp/backup/callcenter'
callcentersubdir=`ls -rtl $callcenterdir|tail -1|awk '{print $NF}'`
callcenternewdir=${callcenterdir}/${callcentersubdir}
if [[ -d $callcenternewdir ]];then
    callcenterstime="$callcentersubdir:014300"
    callcentersize=`du -sm $callcenternewdir|awk '{print $1}'`
    echo "insert into mn_sys_bkrec_dtl_source(seq,source,type,a,b,c,e,f,g,h,i,inserttime)values(seqbkrec_dtl_source.NextVal,'192.168.196.85','ftp','callcenterfullbackup',to_char(to_date('$callcenterstime','yyyymmdd:hh24miss'),'yyyy-mm-dd hh24:mi:ss'),to_char(to_date('$callcenterstime','yyyymmdd:hh24miss'),'yyyy-mm-dd hh24:mi:ss'),'NaN','$callcentersize','notprocess','callcenterfull','已完成',sysdate)"
    echo "insert into mn_sys_bkrec_dtl_source(seq,source,type,a,b,c,e,f,g,h,i,inserttime)values(seqbkrec_dtl_source.NextVal,'192.168.196.85','ftp','callcenterfullbackup',to_char(to_date('$callcenterstime','yyyymmdd:hh24miss'),'yyyy-mm-dd hh24:mi:ss'),to_char(to_date('$callcenterstime','yyyymmdd:hh24miss'),'yyyy-mm-dd hh24:mi:ss'),'NaN','$callcentersize','notprocess','callcenterfull','已完成',sysdate)">>$dataformaturl
    echo "--NEXT">>$dataformaturl
fi